﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Web;
using System.Web.Script.Serialization;

namespace DX_DailyUtil_1._0._1.Web.App_Ctrl.util
{
    public class DB_Util_Json : DB_Util_Base
    {
        public static JavaScriptSerializer mJSJsoner = new JavaScriptSerializer();

        public static String getJson(Type aT, Object aObjt)
        {
            DataContractJsonSerializer _jsoner = new DataContractJsonSerializer(aT);
            String _result = null;
            using (System.IO.MemoryStream _ms = new System.IO.MemoryStream())
            {
                _jsoner.WriteObject(_ms, aObjt);
                _result = System.Text.Encoding.UTF8.GetString(_ms.ToArray());
            }
            return _result;
        }

        public static String getJson_JS(Object aObjt)
        {
            String _result = null;
            _result = mJSJsoner.Serialize(aObjt);
            return _result;
        }

    }
}